home *** CD-ROM | disk | FTP | other *** search
/ Workbench Design / WB Collection.iso / workbench werkzeuge / bildschirmschoner / blitzblank_2.60 / developer / modulesources / bb.guru.c < prev    next >
C/C++ Source or Header  |  1996-04-07  |  4KB  |  209 lines

  1. /*
  2.  * Module: BB.Guru.c
  3.  *
  4.  * Aktion: Zeigt den gefürchteten Guru.
  5.  *
  6.  * Version:
  7.  *   1.1  (27.01.95) Portierung nach BlitzBlank
  8.  *   1.0             Originalimplementation für SuperDark
  9.  *
  10.  * Autor:
  11.  *   Dirk Farin
  12.  *   Kapellenweg 15
  13.  *   72070 Tübingen
  14.  *   Germany
  15.  *
  16.  *   EMail: farindk@trick.informatik.uni-stuttgart.de
  17.  *
  18.  * Copyright:
  19.  *   Dieses Programm ist Freeware, es darf nur
  20.  *   unentgeltlich und unverändert kopiert werden.
  21.  */
  22.  
  23. #define __USE_SYSBASE 1
  24.  
  25. #include <stdio.h>
  26. #include <stdlib.h>
  27. #include <string.h>
  28. #include <math.h>
  29. #include <dos.h>
  30. #include <dos/dos.h>
  31. #include <exec/memory.h>
  32. #include <intuition/intuitionbase.h>
  33. #include <intuition/screens.h>
  34. #include <intuition/intuition.h>
  35. #include <proto/exec.h>
  36. #include <proto/intuition.h>
  37. #include <proto/graphics.h>
  38. #include <proto/dos.h>
  39. #include <blitzblank_pragmas.h>
  40. #include <BlitzBlank.h>
  41.  
  42. struct Library *BlitzBlankBase;
  43.  
  44. char *VersionString="$VER: BB.Guru 1.1 (27.01.95)";
  45.  
  46.  
  47. #define TXTBASE 430
  48.  
  49. #define TXT_INFO 0
  50.  
  51. char *text[]={ "\33c\33uGuru\33n\n\nVersion 1.1\n\nCopyright 1995\nby\nDirk Farin"
  52.              };
  53.  
  54. char* StandardGuru[2] = { "Software failure.       Press left mouse button to continue.",
  55.                           "Error:  8000 0002   Task:  07D829E0" };
  56.  
  57. int   BlinkDelay = 50; // Wartezeit zwischen den Blinkphasen
  58.  
  59. char* txt[2]; // Verweis auf den Text des Gurus
  60.  
  61. struct TextFont* topaz80;
  62. struct TextAttr  topaz80attr = { "topaz.font",8,NULL,NULL };
  63.  
  64. struct BB_Object object[]={ {NULL,BB_Dummy,0,0,0,NULL,NULL} };
  65.  
  66. struct BB_Message message;
  67.  
  68. struct BB_Screeninfo *screeninfo;
  69.  
  70. struct Screen*   scr;
  71. struct RastPort* rp;
  72. struct ViewPort* vp;
  73.  
  74. int ytxtstart[2] = { 15,30 }; // Y-Baseline-Position der beiden Textzeilen
  75.  
  76.  
  77. //----------------------
  78.     void blank (void)
  79. //----------------------
  80. {
  81.   int   guruon=FALSE;   // ob Guru gerade an oder aus ist.
  82.   int   i;
  83.   struct Window* nomousehandle;
  84.  
  85.  
  86.  
  87.   // Texte auswählen
  88.  
  89.   txt[0] = StandardGuru[0];
  90.   txt[1] = StandardGuru[1];
  91.  
  92.  
  93.   // Bildschirm und Zeichensatz öffnen und initialisieren
  94.  
  95.   scr=OpenScreenTags(NULL,
  96.                     SA_Width ,640,
  97.                     SA_Height, 40,
  98.                     SA_Depth,2,
  99.                     SA_DisplayID, HIRES_KEY,
  100.                     SA_Behind,TRUE,
  101.                     SA_Quiet,TRUE,TAG_DONE);
  102.  
  103.   if (!scr) goto cleanexit;
  104.  
  105.   nomousehandle = BBL_BlankMouse( scr,0 );
  106.  
  107.   vp = &scr->ViewPort;
  108.   rp = &scr->RastPort;
  109.  
  110.   SetRGB4(vp,0,0,0,0);
  111.   SetRGB4(vp,1,0,0,0);
  112.   SetRGB4(vp,2,15,0,0);
  113.  
  114.   topaz80 = OpenFont(&topaz80attr);
  115.   if (!topaz80) goto cleanexit;
  116.  
  117.   SetFont(rp,topaz80);
  118.  
  119.  
  120.   // Rahmen malen
  121.  
  122.   SetAPen(rp,1);
  123.   RectFill(rp,0,0,scr->Width-1,scr->Height-1);
  124.  
  125.   SetAPen(rp,0);
  126.   RectFill(rp,5,3,scr->Width-6,scr->Height-4);
  127.  
  128.  
  129.   // Text (zentriert) schreiben
  130.  
  131.   SetAPen(rp,2);
  132.  
  133.   for (i=0;i<2;i++)
  134.   {
  135.     int xpos;
  136.  
  137.     xpos  = scr->Width - TextLength(rp,txt[i],strlen(txt[i]));
  138.     xpos /= 2;
  139.  
  140.     Move(rp,xpos,ytxtstart[i]);
  141.     Text(rp,txt[i],strlen(txt[i]));
  142.   }
  143.  
  144.  
  145.  
  146.   // Blankerschleife: Rahmen blinken
  147.  
  148.   if (!CheckSignal (SIGBREAKF_CTRL_C))
  149.   {
  150.     screeninfo->bbscreen=scr;
  151.     ScreenToFront(scr);
  152.     BBL_ModuleRunning ();
  153.  
  154.     do
  155.     {
  156.       Delay(BlinkDelay);
  157.       if (guruon) { guruon=FALSE; SetRGB4(vp,1, 0,0,0); }
  158.       else        { guruon=TRUE;  SetRGB4(vp,1,15,0,0); }
  159.     }
  160.     while (!CheckSignal (SIGBREAKF_CTRL_C));
  161.   }
  162.  
  163. cleanexit:
  164.   if (topaz80) CloseFont(topaz80);
  165.   if (scr)     { BBL_UnBlankMouse(nomousehandle);
  166.                  CloseScreen(scr);
  167.                }
  168.   return;
  169. }
  170.  
  171.  
  172. //-----------------------------------
  173.     void main(int argc,char **argv)
  174. //-----------------------------------
  175. {
  176.   if (!(BlitzBlankBase=OpenLibrary ("blitzblank.library",BLITZBLANKLIB_VER)))
  177.     exit (0);
  178.  
  179.   message.flags=BBF_NoScreen;
  180.   message.first=&object[0];
  181.  
  182.  
  183.   if (strcmp (argv[1],"BLANK")==0)
  184.   {
  185.     StrToLong (argv[3],(long *) &screeninfo);
  186.     BBL_SendMessage (&message,argv[2]);
  187.     blank ();
  188.     BBL_BlankDone ();
  189.   }
  190.   else
  191.   {
  192.     message.infotext=BBL_GetString (TXT_INFO+TXTBASE,text[TXT_INFO]);
  193.  
  194.     if (strcmp (argv[1],"CONFIG")==0)
  195.     {
  196.       BBL_SendMessage (&message,argv[2]);
  197.     }
  198.     else
  199.     {
  200.       message.first=NULL;
  201.       BBL_SendMessage (&message,argv[2]);
  202.     }
  203.   }
  204.   CloseLibrary (BlitzBlankBase);
  205.   exit (0);
  206. }
  207.  
  208.  
  209.